<?php
App::uses('AppModel', 'Model');
class User extends AppModel {
	var $name = 'User';
	var $displayField = 'name';
	//The Associations below have been created with all possible keys, those that are not needed can be removed
	
	var $hasMany = array(
		'Suggestion' => array(
			'className' => 'Suggestion',
			'foreignKey' => 'user_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		)
	);

	public $validate = array(
		'username' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'Username is required.',
			),
			'isUnique' => array(
				'rule' => array('isUnique'),
				'message' => 'This username has been taken.',
			),
			'maxLength' => array(
				'rule' => array('maxLength', 20),
				'message' => 'Max Length for username is 20 characters'
			)
		),
		'pwd' => array(
			'notempty' => array(
				'rule' => array('notempty'), 
				'message' => 'Password is required'),
			'minLength' => array(
				'rule' => array('minLength', 6),
				'message' => 'Min Length for password is 6 characters'
			)
		),
		'email' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'Email is required.',
			),
			'isUnique' => array(
				'rule' => array('isUnique'),
				'message' => 'This email has been taken.',
			),
			'maxLength' => array(
				'rule' => array('maxLength', 100),
				'message' => 'Max Length for email is 100 characters'
			),
			'email' => array(
				'rule' => array('email'),
				'message' => 'Invalid email address'
			)
		),
	);
}
